home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1992 / 10 / 02 / tips.ampk / Zeichen der Zeit / TimeG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  2.4 KB  |  85 lines

  1. /*  TimeG.c
  2.  *  28.5.1992   (c) by Thomas Göcke, inspiration by ThoF
  3.  *
  4.  *  TimeG ist identisch mit "Time".
  5.  *
  6.  *  Ausnahme:
  7.  *  Die Anzeige der Zeit erfolgt mit Ziffern des Fonts Garnet. Dieser muß
  8.  *  sich im Verzeichnis "fonts:" befinden (eventl. von der Extras1.3
  9.  *  Diskette kopieren).
  10.  *
  11.  *  So kommt ein wenig Abwechslung auf die nüchterne Workbench
  12.  *
  13.  *
  14.  *  Compiler: DICE 2.06.40    (auch als PD / Shareware erhältlich)
  15.  *
  16.  *  Compile Instr.:
  17.  *  dcc TimeG.c -1.3 -o RAM:Time -E RAM:ErrorList -v
  18.  *
  19.  *  Aufruf: Run TimeG
  20.  */
  21.  
  22. #include <exec/types.h>
  23. #include <intuition/intuitionbase.h>
  24. #include <intuition/intuition.h>
  25. #include <time.h>
  26. #include <libraries/dos.h>
  27.  
  28. struct IntuiMessage *message;
  29. struct RastPort *rp;
  30. struct Window *win;
  31. struct NewWindow nwindow =
  32. {
  33.     517, 1, 70, 8, 1, 1,
  34.     CLOSEWINDOW, WINDOWCLOSE | WINDOWDRAG,
  35.     NULL, NULL, "", NULL, NULL, NULL, NULL, NULL, NULL,
  36.     WBENCHSCREEN
  37. };
  38. struct TextFont *txtfnt;    /* Zeiger auf TextFont Struktur */
  39. struct TextAttr txtatt;     /* "      "   TextAttr "        */
  40.  
  41.  
  42. void
  43. CloseAll ()
  44. {
  45.     if (win) CloseWindow (win);
  46.     if (txtfnt != 0) CloseFont (txtfnt);    /* spart Speicher   */
  47.     exit (0);
  48. }
  49.  
  50. main()
  51. {
  52.     char buff[9];
  53.     ULONG MessageClass;
  54.     USHORT code;
  55.  
  56.     if (!(win = (struct Window *) OpenWindow (&nwindow))) CloseAll ();
  57.     rp = win->RPort;    /* Rastport des geöffneten Windows ermittelm        */
  58.     SetAPen (rp, 0);    /* Farbe d. Ziffern = Hintergrundfarbe d. Workbench */
  59.     SetBPen (rp, 1);    /* Hintergrundfarbe = Vordergrundfarbe d. Workbench */
  60.     txtatt.ta_Name = "garnet.font";             /* TextAttr-Struktur füllen */
  61.     txtatt.ta_YSize = 9;                        /* 9-Punkte                 */
  62.     txtatt.ta_Style = 0;                        /* normale Darstellung      */
  63.     txtatt.ta_Flags = 0;
  64.     txtfnt = (struct TextFont *) OpenDiskFont (&txtatt);
  65.     if (txtfnt != 0) SetFont (rp, txtfnt);
  66.     while (1)
  67.     {
  68.         time_t t=time(NULL);
  69.         struct tm *tp = localtime (&t);
  70.         sprintf (buff, "%02d:%02d:%02d ", tp->tm_hour, tp->tm_min, tp->tm_sec);
  71.         Move (rp, 0, 7);
  72.         Text (rp, buff, 9);
  73.         Delay (50);
  74.         WindowToFront (win);
  75.         if (message = (struct IntuiMessage *) GetMsg(win->UserPort))
  76.         {
  77.             MessageClass = message->Class;
  78.             code = message->Code;
  79.             ReplyMsg (message);
  80.             if (MessageClass == CLOSEWINDOW) CloseAll ();
  81.         }
  82.     }
  83. }
  84.  
  85.